<%@ page language="java" contentType="text/html; charset=UTF-8"
  pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<%=request.getContextPath()%>/css/base.css" rel="stylesheet" type="text/css" />
<link href="<%=request.getContextPath()%>/css/admin.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.pager.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/base.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/admin.js"></script>
<title>Insert title here</title>
</head>

<BODY class=list><DIV class=bar>商品品牌&nbsp;总记录数: ${page.totalRowsAmount} (共${page.totalPages}页) </DIV>
<DIV class=body>
<FORM id=listForm name=brandlist method=post action=brandlist.do>
<DIV class=listBar>
<INPUT hideFocus class=formButton onclick="location.href='brandadd.do'" value=添加品牌 type=button>
 &nbsp;&nbsp; <LABEL>查找: </LABEL>
 <INPUT type=text name=searchKey value=${param.searchKey}> 
  &nbsp;&nbsp; <LABEL>类别: </LABEL>
 <INPUT type=text name=type value=${param.type}> 
 <INPUT hideFocus id=searchButton class=formButton value="搜 索" type=button > &nbsp;&nbsp; 
 <LABEL>每页显示: </LABEL>
 <SELECT id=pageSize name=page.pageSize> 
 <OPTION value=10 ${page.pageSize==10?'selected':''}>10</OPTION> 
 <OPTION value=20 ${page.pageSize==20?'selected':''}>20</OPTION> 
 <OPTION value=50 ${page.pageSize==50?'selected':''}>50</OPTION> 
 <OPTION value=100 ${page.pageSize==100?'selected':''}>100</OPTION>
 </SELECT> 
 </DIV>
<TABLE id=listTable class=listTable>
<TBODY>
<TR>
<TH class=check><INPUT class=allCheck type=checkbox > </TH>
<TH><A hideFocus class=sort href="#" name=brandName >品牌名称</A> </TH>
<TH><A hideFocus class=sort href="#" name=goodsType>分类</A> </TH>
<TH><A class=sort href="#" name=sort>排序</A> </TH>
<TH><SPAN>操作</SPAN> </TH></TR>
<c:forEach items="${brandlist}" var="brand">
<TD><INPUT value=${brand.id} type=checkbox name=ids> </TD>
<TD><SPAN title=${brand.brandName}>${brand.brandName}</SPAN></TD>
<TD>${brand.goodsType.typeName} </TD>
<TD>${brand.sort}</TD>
<TD><A title=编辑 href="javascript:brandedit(${brand.id})">[编辑]</A> <A title=删除 href="javascript:del(${brand.id})" >[删除]</A> </TD></TR>
</c:forEach>
</TBODY>
</TABLE>
<DIV class=pagerBar>
<DIV class=pager>
<SPAN id=pager>
</SPAN>
</DIV>
</DIV>


<INPUT id=pageNumber type=hidden name=page.pageNumber value=${page.currentPage} > 
<INPUT id=totalSize type=hidden name=page.totalSize value=${page.totalRowsAmount} > 
<INPUT id=orderBy type=hidden name=pager.orderBy value=${page.orderBy} > 
<INPUT id=order  type=hidden name=pager.order value=${page.order}> 
</FORM>
</DIV>
</BODY>

<SCRIPT type=text/javascript>
$().ready( function() {
	
	var $pager = $("#pager");
	
	$pager.pager({
		pagenumber: ${page.currentPage},
		pagecount: ${page.totalPages},
		buttonClickCallback: $.gotoPage
	});

})

function brandedit(id)
{
  document.brandlist.action="brandedit.do?id="+id;
  document.brandlist.submit(); 
}
function del(id)
{
   $.dialog({type: "warn", content: "您确定要删除吗?", ok: "确 定", cancel: "取 消", modal: true, okCallback: deleteBrand});
   function deleteBrand()
   {
   var url='<%=request.getContextPath()%>/admin/brandremove.do?id='+id;
   $.get(url, function(result){	
        if(result==1)
        {
          $.dialog({type: "success", content: "品牌删除成功！", modal: true, ok:"关闭",okCallback: returnlist});	     
        }else if(result==2)
        {
          $.dialog({type: "error", content: "该品牌下有商品信息，不能删除！", modal: true, autoCloseTime: 3000});
        }	   
	   }); 
	}
}

function returnlist()
{
  document.brandlist.action='brandlist.do?t='+new Date();
  document.brandlist.submit(); 
}
</SCRIPT>
</html>